extends CharacterBody2D

#占用格子小
@export var use_grid_size : Vector2
@onready var attack_cd_timer : Timer = $AttackCdTimer
const base_arrow = preload("res://arrow/base_arrow.tscn")

func _ready():
	attack_cd_timer.timeout.connect(_on_attack)

func _on_attack() :
	var current_scene = get_tree().current_scene
	var is_paused = current_scene.is_paused
	if is_paused : return
	var enemy_list = current_scene.enemy_list
	if enemy_list.get_child_count() > 0 :
		var enemy = enemy_list.get_child(0)
		var arrow = base_arrow.instantiate()
		get_tree().current_scene.call_deferred("add_child",arrow)
		arrow._emit(global_position - Vector2(0,80),enemy)
	pass

func _hurt(params : Dictionary) :
	print(params.damage)
